package com.qiang.work.test09;

import java.io.*;
import java.util.Properties;
import java.util.Set;

public class Demo03 {
    public static void main(String[] args) throws ClassNotFoundException, IOException {
        Properties pop = new Properties();
        //创建读取流
        BufferedReader br = new BufferedReader(new FileReader("day18\\Student.txt"));
//        String s;
//        while ((s = br.readLine()) != null){
//            pop.load(br);
//        }
        pop.load(br);
        br.close();
        //System.out.println(pop);
        Set<Object> keySet = pop.keySet();
        for (Object key : keySet) {
            //System.out.println(key);
            if ("刘方".equals(key)) {
                pop.setProperty("刘方", "18");
            }
        }
        //System.out.println(pop);
        //把新的全部数据写到newstu

        BufferedWriter bw = new BufferedWriter(new FileWriter("day18\\newstu.txt"));
        pop.store(bw, null);
        bw.close();
    }
}
